From: Giovanni Campagna Date: Tue, 22 May 2012 22:27:06 +0000 (+0200) Subject: Show the panel above the screenshield when locked X-Git-Tag: archive/raspbian/50.5-1+rpi1~1^2~1013^2^2~6284 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=c3afe1a83a386d4944fa41ea57d4e223d1687d48;p=gnome-shell.git Show the panel above the screenshield when locked Track locked status and use it to provide a reduced version of the panel in the locked screen. Accessibility, input sources and volume menus are preserved, without the link to the control center. Network, battery and user menu are reduced to pure indicators, with no menu. This is similar to the design but not exactly, because designers in IRC said that network needs more analysis before exposing, and because the design didn't account for a11y and IM (so the one menu metaphor is not really appropriate). https://bugzilla.gnome.org/show_bug.cgi?id=619955 --- diff --git a/js/ui/layout.js b/js/ui/layout.js index 446b590a0..acf6e1f9f 100644 --- a/js/ui/layout.js +++ b/js/ui/layout.js @@ -33,6 +33,12 @@ const LayoutManager = new Lang.Class({ this._chrome = new Chrome(this); + this.screenShieldGroup = new St.Widget({ name: 'screenShieldGroup', + visible: false, + clip_to_allocation: true, + }); + this.addChrome(this.screenShieldGroup); + this.panelBox = new St.BoxLayout({ name: 'panelBox', vertical: true }); this.addChrome(this.panelBox, { affectsStruts: true, @@ -40,12 +46,6 @@ const LayoutManager = new Lang.Class({ this.panelBox.connect('allocation-changed', Lang.bind(this, this._updatePanelBarriers)); - this.screenShieldGroup = new St.Widget({ name: 'screenShieldGroup', - visible: false, - clip_to_allocation: true, - }); - this.addChrome(this.screenShieldGroup); - this.trayBox = new St.BoxLayout({ name: 'trayBox' }); this.addChrome(this.trayBox); this.trayBox.connect('allocation-changed', diff --git a/js/ui/panel.js b/js/ui/panel.js index 648a67790..82c999662 100644 --- a/js/ui/panel.js +++ b/js/ui/panel.js @@ -467,6 +467,13 @@ const AppMenuButton = new Lang.Class({ this._sync(); }, + setLockedState: function(locked) { + if (locked) + this.hide(); + else + this._sync(); + }, + _sync: function() { let tracker = Shell.WindowTracker.get_default(); let focusedApp = tracker.focus_app; @@ -910,6 +917,8 @@ const Panel = new Lang.Class({ this.actor.remove_style_class_name('in-overview'); })); + Main.screenShield.connect('lock-status-changed', Lang.bind(this, this._onLockStateChanged)); + this._menus = new PopupMenu.PopupMenuManager(this); this._leftBox = new St.BoxLayout({ name: 'panelLeft' }); @@ -1135,7 +1144,7 @@ const Panel = new Lang.Class({ this._statusArea[role] = indicator; let destroyId = indicator.connect('destroy', Lang.bind(this, function(emitter) { - this._statusArea[role] = null; + delete this._statusArea[role]; emitter.disconnect(destroyId); })); @@ -1165,4 +1174,16 @@ const Panel = new Lang.Class({ if (box && box._delegate instanceof PanelMenu.ButtonBox) box.destroy(); }, + + _onLockStateChanged: function(shield, locked) { + if (this._activitiesButton) + this._activitiesButton.setLockedState(locked); + if (this._appMenu) + this._appMenu.setLockedState(locked); + if (this._dateMenu) + this._dateMenu.setLockedState(locked); + + for (let id in this._statusArea) + this._statusArea[id].setLockedState(locked); + }, }); diff --git a/js/ui/panelMenu.js b/js/ui/panelMenu.js index 0d8c84aaf..f1800694b 100644 --- a/js/ui/panelMenu.js +++ b/js/ui/panelMenu.js @@ -145,6 +145,13 @@ const Button = new Lang.Class({ } }, + setLockedState: function(locked) { + // default behaviour is to hide completely + if (locked) + this.menu.close(); + this.actor.visible = !locked; + }, + _onButtonPress: function(actor, event) { if (!this.menu) return; diff --git a/js/ui/popupMenu.js b/js/ui/popupMenu.js index beb26cde4..7570d6ebc 100644 --- a/js/ui/popupMenu.js +++ b/js/ui/popupMenu.js @@ -872,6 +872,7 @@ const PopupMenuBase = new Lang.Class({ this._activeMenuItem = null; this._childMenus = []; + this._settingsActions = { }; }, addAction: function(title, callback) { @@ -899,9 +900,19 @@ const PopupMenuBase = new Lang.Class({ Main.overview.hide(); app.activate(); }); + + this._settingsActions[desktopFile] = menuItem; + return menuItem; }, + setSettingsVisibility: function(visible) { + for (let id in this._settingsActions) { + let item = this._settingsActions[id]; + item.actor.visible = visible; + } + }, + isEmpty: function() { return this.box.get_n_children() == 0; }, diff --git a/js/ui/status/accessibility.js b/js/ui/status/accessibility.js index 20c54c6e1..35cd6fece 100644 --- a/js/ui/status/accessibility.js +++ b/js/ui/status/accessibility.js @@ -83,6 +83,10 @@ const ATIndicator = new Lang.Class({ this.menu.addSettingsAction(_("Universal Access Settings"), 'gnome-universal-access-panel.desktop'); }, + setLockedState: function(locked) { + this.menu.setSettingsVisibility(!locked); + }, + _buildItemExtended: function(string, initial_value, writable, on_set) { let widget = new PopupMenu.PopupSwitchMenuItem(string, initial_value); if (!writable) diff --git a/js/ui/status/bluetooth.js b/js/ui/status/bluetooth.js index 2d3b9b84b..b68b8433c 100644 --- a/js/ui/status/bluetooth.js +++ b/js/ui/status/bluetooth.js @@ -92,6 +92,11 @@ const Indicator = new Lang.Class({ this._applet.connect('cancel-request', Lang.bind(this, this._cancelRequest)); }, + setLockedState: function(locked) { + this._isLocked = locked; + this._updateKillswitch(); + }, + _updateKillswitch: function() { let current_state = this._applet.killswitch_state; let on = current_state == GnomeBluetoothApplet.KillswitchState.UNBLOCKED; @@ -106,7 +111,7 @@ const Indicator = new Lang.Class({ /* TRANSLATORS: this means that bluetooth was disabled by hardware rfkill */ this._killswitch.setStatus(_("hardware disabled")); - this.actor.visible = has_adapter; + this.actor.visible = !this._isLocked && has_adapter; if (on) { this._discoverable.actor.show(); diff --git a/js/ui/status/keyboard.js b/js/ui/status/keyboard.js index 6d3b04196..ce32d0192 100644 --- a/js/ui/status/keyboard.js +++ b/js/ui/status/keyboard.js @@ -175,11 +175,16 @@ const InputSourceIndicator = new Lang.Class({ // option if need arises. if (Main.sessionMode.allowSettings) { this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem()); - this.menu.addAction(_("Show Keyboard Layout"), Lang.bind(this, this._showLayout)); + this._showLayoutItem = this.menu.addAction(_("Show Keyboard Layout"), Lang.bind(this, this._showLayout)); } this.menu.addSettingsAction(_("Region and Language Settings"), 'gnome-region-panel.desktop'); }, + setLockedState: function(locked) { + this._showLayoutItem.actor.visible = !locked; + this.menu.setSettingsVisibility(!locked); + }, + _currentInputSourceChanged: function() { let nVisibleSources = Object.keys(this._layoutItems).length; if (nVisibleSources < 2) diff --git a/js/ui/status/network.js b/js/ui/status/network.js index 5a3210bfb..301ebcb01 100644 --- a/js/ui/status/network.js +++ b/js/ui/status/network.js @@ -1698,6 +1698,15 @@ const NMApplet = new Lang.Class({ this._primaryIcon.icon_name = iconName; }, + setLockedState: function(locked) { + // FIXME: more design discussion is needed before we can + // expose part of this menu + + if (locked) + this.menu.close(); + this.actor.reactive = !locked; + }, + _ensureSource: function() { if (!this._source) { this._source = new MessageTray.Source(_("Network Manager"), diff --git a/js/ui/status/power.js b/js/ui/status/power.js index 978d009b9..8d2e00bfd 100644 --- a/js/ui/status/power.js +++ b/js/ui/status/power.js @@ -80,6 +80,12 @@ const Indicator = new Lang.Class({ this._devicesChanged(); }, + setLockedState: function(locked) { + if (locked) + this.menu.close(); + this.actor.reactive = !locked; + }, + _readPrimaryDevice: function() { this._proxy.GetPrimaryDeviceRemote(Lang.bind(this, function(result, error) { if (error) { diff --git a/js/ui/status/volume.js b/js/ui/status/volume.js index 6951cb167..9a085a24b 100644 --- a/js/ui/status/volume.js +++ b/js/ui/status/volume.js @@ -62,6 +62,10 @@ const Indicator = new Lang.Class({ this._control.open(); }, + setLockedState: function(locked) { + this.menu.setSettingsVisibility(!locked); + }, + _onScrollEvent: function(actor, event) { let direction = event.get_scroll_direction(); let currentVolume = this._output.volume; diff --git a/js/ui/userMenu.js b/js/ui/userMenu.js index ff4e58024..eea414649 100644 --- a/js/ui/userMenu.js +++ b/js/ui/userMenu.js @@ -538,6 +538,12 @@ const UserMenuButton = new Lang.Class({ this._upClient.connect('notify::can-suspend', Lang.bind(this, this._updateSuspendOrPowerOff)); }, + setLockedState: function(locked) { + if (locked) + this.menu.close(); + this.actor.reactive = !locked; + }, + _onDestroy: function() { this._user.disconnect(this._userLoadedId); this._user.disconnect(this._userChangedId);